<template>
  <div class="about">
    <h1>login</h1>
    <el-button @click="login('1')">登录</el-button>
    <el-button @click="login('2')">注册</el-button>
    <p>{{value}}</p>
  </div>
</template>
<script>
import { mapActions } from 'vuex';
export default {
  data() {
    return {
      value: "",
    };
  },
  methods: {
    ...mapActions(['SetUserToken']),
    login(type) {
      if(type === '1') {
        this.SetUserToken().then(()=>{
          this.$router.push({
            path: '/index',
            query: { hasLogin: '1', name: this.$store.state.info.name }
          })
        })
      }else {
        alert('注册成功！')
      }
    },
  },
};
</script>
